import request from '@/utils/request'
import { data } from 'autoprefixer'
//1.查询级联关系的菜单集合
export const listMenus = () => {
  return request({
    url: `/admin/system/sysMenu/findNodes`,
    method: 'get',
  })
}
//2.删除
export const DeleteById = id => {
  return request({
    url: `/admin/system/sysMenu/${id}`,
    method: 'delete',
  })
}
//3.根据id查询菜单
export const GetById = id => {
  return request({
    url: `/admin/system/sysMenu/${id}`,
    method: 'get',
  })
}
//4.根据id更新菜单
export const UpdateById = data => {
  return request({
    url: `/admin/system/sysMenu`,
    method: 'put',
    data,
  })
}
//5.新增菜单
export const Save = data => {
  return request({
    url: `/admin/system/sysMenu`,
    method: 'post',
    data,
  })
}
//6.查询所有可用菜单和已分配的菜单id集合
export const GetMenuByRoleId = roleId => {
  return request({
    url: `/admin/system/sysMenu/role/listMenus/${roleId}`,
    method: 'get',
  })
}
//7.给角色分配菜单
export const AssignMenuToRole = (roleId, menuIds) => {
  return request({
    url: `/admin/system/roleMenu/assignMenus/${roleId}`,
    method: 'put',
    data: menuIds,
  })
}
